<?php
namespace app\extensions\lib;
/**
 *
 */
class Output
{
    /**
     * 成功
     * @param array $data
     * @return \support\Response
     */
    public static function success($data = []){
        return self::do(CODE_SUCCESS,'success',$data);
    }

    /**
     * 抛出异常
     * @param array $data
     * @param string $code
     * @param string $msg
     * @return \support\Response
     */
    public static function exception($data = [],$code='',$msg=''){
        return self::do($code ?:CODE_EXCEPTION,$msg,$data);
    }



    public static function do($code,$msg,Array $data = []){
        $respData = ['code' => $code,'msg' => $msg , 'data' => $data];
        return json($respData);
    }
}